package design.masterWorker;

import java.util.concurrent.Callable;

public class SalaryRunner implements Runnable {
    //结果
    private Result result;
    // 工资
    private long salary;
    // 耗时
    private long costTime;

    public SalaryRunner(Result result,long salary, long costTime) {
        this.result = result;
        this.salary = salary;
        this.costTime = costTime;
    }


    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " sleep=" + costTime +"salary*costTime="+ salary*costTime );
        try {
            this.result.setValue(salary*costTime);
            Thread.sleep(costTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
